<extend name="Public/base" />
<block name="content">
<!-- 配置文件 -->
<script type="text/javascript" src="__STATIC__/ueditor/ueditor.config.all.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="__STATIC__/ueditor/ueditor.all.js"></script>
<div id="content">
	<div id="content-header">
		<div id="breadcrumb">
			<a href="{:U('Index/index')}" title="首页" class="tip-bottom"><i
				class="icon-home"></i> 首页</a> <a href="#" class="current">{$meta_title}</a>
		</div>
	</div>
	<div class="container-fluid">
		<br/>
		
			<a class="btn btn-warning" href="{$back_url}">返 回</a>
		
		
		<div class="row-fluid">
			<div class="span12">
				<div class="widget-box">
					<div class="widget-content ">
						<form action="#" method="get" class="form-horizontal" autocomplete="off">
							<div class="control-group">
								<label class="control-label">模板名称 :</label>
								<div class="controls">
									<input type="text" name="theme_name" class="ui-wizard-content span3" value="{$info.theme_name|htmlspecialchars}" />
								</div>
							</div>
							
							<div class="control-group " >
								<label class="control-label">展示活动 :</label>
								<div class="controls" style="height:30px; ">
									<select class="form-control span2" name="activity_id" id="activity_id" >
										<option value=0>请选择活动</option>
										<volist name="activity_list" id="vo">
											<option value='{$vo.activity_id}'>{$vo.activity_name|strip_tags|htmlspecialchars}</option>
										</volist>
									</select>
								</div>
							</div>
							
							<label class="control-label">展示时间 :</label>
							<div class="controls">
								<input type="text" placeholder="展示时间" name="start_time" class="datepicker span2" value='<neq name="info.start_time" value="">{:time_format($info["start_time"],"Y-m-d H:i")}</neq>'>
								<span class="label label-important" id="start" style="display:none"></span>
							</div>
							<label class="control-label">结束时间 :</label>
							<div class="controls">
								<input type="text" placeholder="结束时间" name="end_time" class="datepicker span2" value='<neq name="info.end_time" value="">{:time_format($info["end_time"],"Y-m-d H:i")}</neq>'>
								<span class="label label-important" id="end" style="display:none"></span>
							</div>
							
							<div class="control-group">
				            	<label class="control-label">模板类型 :</label>
				            	<div class="controls" style="height:30px; margin-top:5px;">
					                <label style="width:80px; float:left"><input type="radio" name="type" value="0" checked />网页版</label>
					                <label style="width:80px; float:left"><input type="radio" name="type" value="1" />手机版</label>
				            	</div>
				            </div>
							
							<div class="control-group">
								<label class="control-label">模板顶部 :</label>
								<div class="controls">
									<!-- 加载编辑器的容器 -->
								    <textarea name="content_head" type="text/plain" style="width:90%; height:100px;">{$info.content_head}</textarea>
								</div>
							</div>
							<if condition="$info eq null">
								<div class="control-group">
									<label class="control-label">模板规则 :</label>
									<div class="controls">
										<textarea type="text" disabled class="ui-wizard-content span6" style="height:100px;" />{$msg}</textarea>
									</div>
								</div>
								<div class="control-group">
									<label class="control-label">模板内容 :</label>
									<div class="controls">
										<!-- 加载编辑器的容器 -->
									    <textarea id="container" name="content" type="text/plain">{$info.content}</textarea>
									</div>
								</div>
							</if>
							<div class="control-group">
								<label class="control-label">模板底部 :</label>
								<div class="controls">
									<!-- 加载编辑器的容器 -->
								    <textarea name="content_foot" type="text/plain" style="width:90%; height:100px;">{$info.content_foot}</textarea>
								</div>
							</div>
							
							<div class="controls">
								<button type="button" id="submit" class="btn btn-success">提 交</button>
								<input type="hidden" value="{$info.activity_theme_id|default=0}" name="activity_theme_id">
								<input type="hidden" value="{$info.status|default=1}" name="status">
								<input type="hidden" value="{$back_url}" name="url">
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
$(function(){
	//日期控件
	$(".datepicker").datetimepicker({
		format: 'yyyy-mm-dd hh:ii', 
	  	startDate:new Date(), //开始时间，在这时间之前都不可选
	  	//endDate:'+1',//结束时间，在这时间之后都不可选
	    autoclose: true,
	    todayBtn: true,
	    todayHighlight: true,
	});
	<if condition="$info eq null">
	//ueditor
	var ue = UE.getEditor('container',{
	    allowDivTransToP: false,
	    initialFrameHeight: 300,
	    toolbars: [
			['fullscreen', 'source', 'undo', 'redo', 'bold', 'italic', 'underline', 'fontborder', 'backcolor', 'fontsize', 'fontfamily', 'justifyleft', 'justifyright', 'justifycenter', 'justifyjustify', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', 'link', 'unlink']
		]
	});
	</if>
	//submit
	$("#submit").click(function(){
		//锁定提交按钮
		$(this).attr('disabled',true);
		//编辑器HTML切换
		$('#edui4_body').trigger('click');
		var self = $('form');
		$.post("{:U('Activity/activityThemeAdd')}", self.serialize(), call_back, "json");
		return false;
		/**
		 * @todo 接收返回值
		 */
		function call_back(data){
			if(data.status == 1){
				tke_alert(data.info,'alert-success');
				setTimeout(function(){
					location.href = data.url + '#{:NOW_TIME}';
				},1000);
			} else {
				tke_alert(data.info,'alert-error');
				$("#submit").attr('disabled',false);
			}
		}
	});
	
	//动态获取活动 岂止时间
	$('#activity_id').change(function(){
		var activity_id = $.trim($(this).val());
		if(activity_id ==0){
			tke_alert('请选择有效的活动','alert-error');
			return false;
		}
		$.post("{:U('getActivityTime')}", {activity_id:activity_id}, function(data){	
			if(data.status==1){
				$('#start').html(data['data']['show_start_time']);
				$('#end').html(data['data']['show_end_time']);
			}else{
				$('#start').html('');
				$('#end').html('');
			}
			$('#start,#end').show();
		}, "json");
	});
});
$(function (){
	set_value("activity_id","{$info.activity_id}")
	<if condition="$info neq 0">
		set_value("type","{$info.type}");
	</if>
		
});
//导航高亮
highlight_subnav("{:U('Activity/activityTheme')}");
</script>
</block>